package com.sc.VenusQueryBeta.presenter.hotel.tabs;

import com.hengjun.kingstar.sdk.utils.LogUtils;
import com.sc.VenusQueryBeta.contract.hotel.tabs.PriceContract;
import com.sc.VenusQueryBeta.model.bean.home.HotelPriceBean;
import com.sc.VenusQueryBeta.model.hotel.tabs.PriceModel;

import io.reactivex.functions.Consumer;

/**
 * 酒店价格Presenter
 */

public class PricePresenter extends PriceContract.PricePresenter{
    @Override
    protected PriceContract.IPriceModel getModel() {
        return PriceModel.newInstance();
    }

    /**
     * 实例化对象
     */
    public static PricePresenter newInstance(){
        return new PricePresenter();
    }
    @Override
    public void onStart() {

    }

    @Override
    public void loadLatestList() {

    }

    @Override
    public void loadMoreList() {

    }

    @Override
    public void onItemClick(int position, Object item) {

    }

    @Override
    public void getHotelPriceData(int vipClubId) {
        mRxManager.register(mIModel.getHotelPrice(vipClubId).subscribe(new Consumer<HotelPriceBean>() {

            @Override
            public void accept(HotelPriceBean hotelPriceBean) throws Exception {
                if (mIView != null)
                    mIView.showHotelPriceDataSuccess(hotelPriceBean);
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {
                LogUtils.e("error="+throwable.getLocalizedMessage());
                if (mIView != null) {
//                    if (mIView.isVisiable())
//                        mIView.showToast("Network error.");
                    mIView.showNetworkError();
                }
            }
        }));
    }
}
